Repository navigation
fix(cli): repair search and status commands - #69
Merged
Merged
Conversation
…s_fts table
`pi-session-cli search` called the app command `search_sessions_fts`, which runs
`SELECT path FROM sessions_fts WHERE sessions_fts MATCH ?`. Since message-level
FTS became the primary search path, the schema no longer creates `sessions_fts`
(see `ensure_message_fts_schema` in data/sqlite/bootstrap.rs, which is now the
only index built; `init_fts5`, the only caller of `full_rebuild_fts`, is unused),
so the command always failed with:
Command failed: 命令 'search_sessions_fts' 失败:
Failed to prepare FTS5 statement: no such table: sessions_fts
Route the CLI at `full_text_search` instead, which queries the maintained
message-level index and returns scored hits with content snippets.
Refs Dwsy#62
`pi-session-cli status` requested `GET /health`, but the axum router in
src/server/http/mod.rs registers no `/health` route, so the request fell through
to the SPA handler and the CLI reported:
服务端返回了非 JSON 响应 (http://localhost:52131/health) — 可能服务端版本不匹配
Probe `/health` first (kept for deployments that do expose it) and fall back to
`/v1/observability/summary`, which reports the supported capabilities and
endpoints and is served in both desktop and headless modes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
pi-session-clicannot run two of its commands against the current server (reproduced on the v0.8.6 release binaries and onmain=a09ae455, which is the same commit the tag points at):pi-session-cli search <query>Command failed: 命令 'search_sessions_fts' 失败: Failed to prepare FTS5 statement: no such table: sessions_ftspi-session-cli statusCommand failed: 服务端返回了非 JSON 响应 (http://localhost:52131/health) — 可能服务端版本不匹配Two independent causes, one commit each.
1.
search— the legacysessions_ftstable is gonesrc-tauri-cli/src/run.rscalls the app commandsearch_sessions_fts, which resolves todata/sqlite/legacy_fts.rs::search_fts5():Since message-level FTS became the primary search path,
data/sqlite/bootstrap.rsonly buildsensure_message_fts_schema()and notes "Legacy session-level FTS remains disabled regardless of config";init_fts5()— the only caller offull_rebuild_fts()— has no callers left, sosessions_ftsis never created and the command always fails.This is the bug reported in #62. That issue is closed as "Fixed by 208190a4: CLI session search now uses the current message_fts index instead of the removed sessions_fts table", but that commit does not exist in this repository, and the failure still reproduces on
main/v0.8.6:This PR does what that closing comment describes — the CLI now uses the current
message_ftsindex, via the existingfull_text_searchcommand (same one the UI's search uses):Result: scored message hits with content snippets,
session_pathand timestamps (previously the command returned up to 50SessionInforows; message-level hits are what the maintained index can serve).2.
status— there is no/healthroute to proberequest_status()requestsGET {base_url}/health. The router insrc/server/http/mod.rsregisters/api,/api/events,/v1/*,/wsand/metrics— no/health, so the request falls through to the embedded-SPA handler, which answers withindex.html, andresp.json()fails on the HTML.The fix keeps
/healthas the first probe (for deployments that do expose it) and falls back to/v1/observability/summary, which is served in desktop and headless mode and reports exactly whatstatusis for:Testing
Built with
cargo build --release -p pi-session-cli(featurecli, no Tauri/WebKit needed) and run against a running 0.8.6 desktop app with a schema-v19 database (~/.pi/agent/sessions/sessions.db), which is the environment from #62:session list,session get,tag,modeletc. are untouched and still work.Alternatives considered
search_sessions_ftsfall back to the message index, so existing CLI builds keep working too. That changes the command's return shape (Vec<SessionInfo>→ hits), so it is a behavioural change on a public command — happy to implement it instead if you prefer that direction./healthroute server-side rather than adjusting the client. Also fine by me if you would rather have the conventional endpoint.Both commits are independent — happy to split them into separate PRs if that is easier to review.